{extend name="public/base" /}

{block name="title"}<title>{$Think.lang.list}</title>{/block}

{block name="pjax_container"}
<div class="hry-content-wrapper">
<section class="content-header">
    <ol class="breadcrumb">
        <li>企业端管理</li>
        <li class="active">会员兑付</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="hry-form-wrapper">
                <div class="box-header with-border" style="padding:15px;">
                    <h3 class="box-title"></h3>
                    {include file="public/project_side_member_duifu_search" /}
                </div>
                <div class="box-body table-responsive">
                    <div style="margin-top: 10px;text-align: right;margin-right: 10px;margin-bottom: 10px">
                        {if condition="$projectId > 0  && $isShow > 0"}
                        <button type="button" class="btn btn-primary batch-duifu" data-project-id="{$projectId}">一键批量兑付</button>
                        {/if}
                    </div>
                    <table class="table table-bordered table-hover table-sort">
                        <tr>
                            <th>订单ID{:table_sort('id')}</th>
                            <th>认投订单号</th>
                            <th>姓名</th>
                            <th>手机号</th>
							<th>认投金额</th>
							<th>所属项目</th>
                            <th>项目方</th>
                            <th>收益比例</th>
                            <th>兑付金额</th>
                            <th>备注</th>
                            <th>状态</th>
                            <th width="178">{$Think.lang.action}</th>
                        </tr>
                        {volist name="dataList" id="vo"}
                        <tr>
                            <td>{$vo.id}</td>
                            <td>{$vo.order_sn}</td>
                            <td>{$vo.username}</td>
                            <td>{$vo.mobile}</td>
                            <td>{$vo.rt_money}</td>
                            <td>{$vo.project_name}</td>
                            <td>{$vo.company_name}</td>
                            <td>{$vo.money_profit*100}%</td>
							<td>{$vo.df_money}</td>
                            <td>{$vo.remarks}</td>
                            {if condition="$vo.status eq 1"}
                            <td><span class="status status-warning">未兑付</span></td>
                            <td>
                                <a class="btn-text btn-primary duifu" data-id="{$vo.id}"  data-order-id="{$vo.order_id}">兑付</a>
                            </td>
                            {/if}
                            {if condition="$vo.status eq 2"}
                            <td><span class="status status-success">已兑付</span></td>
                            <td></td>
                            {/if}
                            {if condition="$vo.status eq 3"}
                            <td><span class="status status-error">兑付失败</span></td>
                            <td></td>
                            {/if}

                        </tr>
                        {/volist}
                    </table>
                </div>
            </div>
            <div class="box-footer clearfix"> {$dataList->render()}</div>
        </div>
    </div>
</section>
</div>
<script type="text/javascript">
$(function(){
    $('.duifu').on('click', function () {
        let id = $(this).attr('data-id')
        let orderid = $(this).attr('data-order-id')
        let obj = {
            id: id,
            order_id: orderid
        }
        $.ajax({
            url: '/hryweb.php/project_side/confirmDuiFu',
            data: obj,
            type: "POST",
            dataType: "json",
            success: function (result) {
                if (result.status == 1) {
                    $.amaran({'message': result.info});
                    window.location.reload()
                } else {
                    $.amaran({'message': result.info});
                }
            },
            error: function (result, xhr, status, errorThrown) {
                $.amaran({'message': result.info})
            },
            complete: function (xhr, status) {
//                    alert('The request is complated');
            },
            beforesend: function () {
            },
            cache: false,//true
            async: true
        })
    })
    $('.batch-duifu').on('click', function () {
        let id = $(this).attr('data-project-id')
        let obj = {
            project_id: id
        }
        $.ajax({
            url: '/hryweb.php/project_side/batchDuiFuOrderPay',
            data: obj,
            type: "POST",
            dataType: "json",
            success: function (result) {
                if (result.status == 1) {
                    $.amaran({'message': result.info});
                    window.location.reload()
                } else {
                    $.amaran({'message': result.info});
                }
            },
            error: function (result, xhr, status, errorThrown) {
                $.amaran({'message': result.info})
            },
            complete: function (xhr, status) {
//                    alert('The request is complated');
            },
            beforesend: function () {
            },
            cache: false,//true
            async: true
        })
    })
    {if condition=" $rest_login == 1 "}
    restlogin('{$rest_login_info}');   //登录超时
    {/if}
})

</script>
<style>
    .status{
        display: inline-block;
        padding: 3px 15px;
        color: white;
        border-radius: 15px;
        font-size: 12px;
    }
    .status-error{
        background: #f5222d;
    }
    .status-success{
        background: #52c41a;
    }
    .status-warning{
        background: #faad14;
    }
</style>
{/block}